package java4_2.Homework3;

public class Time extends Thread{
    private boolean finished = false;
    public void isFinished(boolean b){
        this.finished = b;
    }
    @Override
    public void run() {
        int istime = 0;
        while (!finished && istime<40){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            istime++;
        }
        if (!finished){
            System.out.println("时间到,系统即将退出！");
            System.exit(0);
        }
    }
}
